/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  
  checkConfig(config);
  @endpoint = getEndpoint('resourcesharing', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model AcceptResourceShareInvitationRequest {
  resourceShareInvitationId?: string(name='ResourceShareInvitationId', description='The ID of the resource sharing invitation.

You can call the [ListResourceShareInvitations](https://help.aliyun.com/document_detail/450564.html) operation to obtain the ID.

This parameter is required.', example='i-pMnItMX19fBJ****'),
}

model AcceptResourceShareInvitationResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='08F18B04-47CB-5C0E-A6D2-37DEF5C2A961'),
  resourceShareInvitation?: {
    acceptInvitationFailedDetails?: [ 
      {
        associateType?: string(name='AssociateType', description='This parameter is deprecated. The OperationType parameter is used instead.', example='Associate'),
        failureDescription?: string(name='FailureDescription', description='The failure description.', example='You cannot access the specified resource at this time.'),
        failureReason?: string(name='FailureReason', description='The failure cause. Valid values:

*   Unavailable: The resource cannot be shared.
*   LimitExceeded: The number of shared resources within the Alibaba Cloud account exceeds the upper limit.
*   ZonalResourceInaccessible: The resource is unavailable in this region.
*   InternalError: An internal error occurred during the check.', example='Unavailable'),
        operationType?: string(name='OperationType', description='The operation type. Valid values:

*   Associate', example='Associate'),
        resourceId?: string(name='ResourceId', description='The ID of the shared resource.', example='s-7xvh46nx5oqlre0wv***'),
        resourceType?: string(name='ResourceType', description='The type of the shared resource.

For more information about the types of resources that can be shared, see [Services that work with Resource Sharing](https://help.aliyun.com/document_detail/450526.html).', example='Snapshot'),
        status?: string(name='Status', description='This parameter is deprecated. The FailureReason parameter is used instead.', example='Unavailable'),
        statusMessage?: string(name='StatusMessage', description='This parameter is deprecated. The FailureDescription parameter is used instead.', example='You cannot access the specified resource at this time.'),
      }
    ](name='AcceptInvitationFailedDetails', description='The information about the failure.'),
    createTime?: string(name='CreateTime', description='The time when the invitation was created. The time is displayed in UTC.

This parameter is required.', example='2022-09-02T06:43:12.353Z'),
    receiverAccountId?: string(name='ReceiverAccountId', description='The Alibaba Cloud account ID of the invitee.

This parameter is required.', example='134254031178****'),
    resourceShareId?: string(name='ResourceShareId', description='The ID of the resource share.

This parameter is required.', example='rs-ysGRci9z****'),
    resourceShareInvitationId?: string(name='ResourceShareInvitationId', description='The ID of the resource sharing invitation.

This parameter is required.', example='i-pMnItMX19fBJ****'),
    resourceShareName?: string(name='ResourceShareName', description='The name of the resource share.

This parameter is required.', example='example'),
    senderAccountId?: string(name='SenderAccountId', description='The Alibaba Cloud account ID of the inviter.

This parameter is required.', example='151266687691****'),
    status?: string(name='Status', description='The status of the invitation. Valid values:

*   Pending
*   Accepted
*   Cancelled
*   Rejected
*   Expired
*   AcceptFailed

This parameter is required.', example='AcceptFailed'),
  }(name='ResourceShareInvitation', description='The information about the resource sharing invitation.'),
}

model AcceptResourceShareInvitationResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: AcceptResourceShareInvitationResponseBody(name='body'),
}

/**
 * @summary Accepts a resource sharing invitation.
 *
 * @description ### [](#)
 * *   A principal needs to accept or reject a resource sharing invitation only if the principal is not the management account or a member of a resource directory. If you share resources with an object in a resource directory, the system automatically accepts the resource sharing invitation for the object.
 * *   A resource sharing invitation is valid for seven days. A principal must accept or reject the invitation within the validity period.
 * This topic provides an example on how to call the API operation to accept the resource sharing invitation whose ID is `i-pMnItMX19fBJ****` in the `cn-hangzhou` region.
 *
 * @param request AcceptResourceShareInvitationRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return AcceptResourceShareInvitationResponse
 */
async function acceptResourceShareInvitationWithOptions(request: AcceptResourceShareInvitationRequest, runtime: Util.RuntimeOptions): AcceptResourceShareInvitationResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.resourceShareInvitationId)) {
    query['ResourceShareInvitationId'] = request.resourceShareInvitationId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'AcceptResourceShareInvitation',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Accepts a resource sharing invitation.
 *
 * @description ### [](#)
 * *   A principal needs to accept or reject a resource sharing invitation only if the principal is not the management account or a member of a resource directory. If you share resources with an object in a resource directory, the system automatically accepts the resource sharing invitation for the object.
 * *   A resource sharing invitation is valid for seven days. A principal must accept or reject the invitation within the validity period.
 * This topic provides an example on how to call the API operation to accept the resource sharing invitation whose ID is `i-pMnItMX19fBJ****` in the `cn-hangzhou` region.
 *
 * @param request AcceptResourceShareInvitationRequest
 * @return AcceptResourceShareInvitationResponse
 */
async function acceptResourceShareInvitation(request: AcceptResourceShareInvitationRequest): AcceptResourceShareInvitationResponse {
  var runtime = new Util.RuntimeOptions{};
  return acceptResourceShareInvitationWithOptions(request, runtime);
}

model AssociateResourceShareRequest {
  permissionNames?: [ string ](name='PermissionNames', description='The information about the permissions. If you do not configure this parameter, the system automatically associates the default permission for the specified resource type with the resource share. For more information, see [Permission library](https://help.aliyun.com/document_detail/465474.html).'),
  resourceShareId?: string(name='ResourceShareId', description='The ID of the resource share.

This parameter is required.', example='rs-6GRmdD3X****'),
  resources?: [ 
    {
      resourceId?: string(name='ResourceId', description='The ID of a shared resource.

Valid values of N: 1 to 5. This indicates that a maximum of five shared resources can be specified at a time.

>  Resources.N.ResourceId and Resources.N.ResourceType must be used in pairs.', example='vsw-bp183p93qs667muql****'),
      resourceType?: string(name='ResourceType', description='The type of a shared resource.

Valid values of N: 1 to 5. This indicates that a maximum of five shared resources can be specified at a time.

For more information about the types of resources that can be shared, see [Services that work with Resource Sharing](https://help.aliyun.com/document_detail/450526.html).

>  `Resources.N.ResourceId` and `Resources.N.ResourceType` must be used in pairs.', example='VSwitch'),
    }
  ](name='Resources', description='The information about the resources.'),
  targetProperties?: [ 
    {
      property?: string(name='Property', description='The property parameter of the principal. For example, you can specify a parameter that indicates the time range for resource sharing. Valid values of `timeRangeType`:

*   timeRange: a specific time range
*   day: all day

>  `TargetProperties.N.TargetId` and `TargetProperties.N.Property` must be used in pairs.', example='{
    "timeRange":{
        "timeRangeType":"timeRange",
        "beginAtTime":"00:00",
        "timezone":"UTC+8",
        "endAtTime":"19:59"
    }
}'),
      targetId?: string(name='TargetId', description='The ID of the principal.

>  `TargetProperties.N.TargetId` and `TargetProperties.N.Property` must be used in pairs.', example='172050525300****'),
    }
  ](name='TargetProperties', description='The properties of the principal.

>  This parameter is available only when you specify an Alibaba Cloud service as a principal.'),
  targets?: [ string ](name='Targets', description='The information about the principals.', example='172050525300****'),
}

model AssociateResourceShareResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='111FB84A-60A9-403E-9067-E55D7EE95BD1'),
  resourceShareAssociations?: [ 
    {
      associationStatus?: string(name='AssociationStatus', description='The association status. Valid values:

*   Associating: The entity is being associated.
*   Associated: The entity is associated.
*   Failed: The entity fails to be associated.
*   Disassociating: The entity is being disassociated.
*   Disassociated: The entity is disassociated.

>  The system deletes the records of entities in the `Failed` or `Disassociated` state within 48 hours to 96 hours.', example='Associating'),
      associationStatusMessage?: string(name='AssociationStatusMessage', description='The cause of the association failure.', example='The reason for the association failure.'),
      associationType?: string(name='AssociationType', description='The association type. Valid values:

*   Resource
*   Target', example='Resource'),
      createTime?: string(name='CreateTime', description='The time when the association of the entity was created. The value of this parameter depends on the value of the AssociationType parameter:

*   If the value of `AssociationType` is `Resource`, the value of this parameter is the time when the shared resource was associated with the resource share.
*   If the value of `AssociationType` is `Target`, the value of this parameter is the time when the principal was associated with the resource share.', example='2020-12-04T09:40:41.246Z'),
      entityId?: string(name='EntityId', description='The ID of the entity. The value of this parameter depends on the value of the AssociationType parameter:

*   If the value of `AssociationType` is `Resource`, the value of this parameter is the ID of the shared resource.
*   If the value of `AssociationType` is `Target`, the value of this parameter is the ID of the principal.', example='vsw-bp183p93qs667muql****'),
      entityType?: string(name='EntityType', description='The type of the entity. The value of this parameter depends on the value of the AssociationType parameter:

*   If the value of AssociationType is Resource, the value of this parameter is the type of the shared resource. For information about the types of resources that can be shared, see [Services that work with Resource Sharing](https://help.aliyun.com/document_detail/450526.html).
*   If the value of AssociationType is Target, the value of this parameter is `Account`.', example='VSwitch'),
      resourceShareId?: string(name='ResourceShareId', description='The ID of the resource share.', example='rs-6GRmdD3X****'),
      resourceShareName?: string(name='ResourceShareName', description='The name of the resource share.', example='test'),
      targetProperty?: string(name='TargetProperty', description='The properties of the principal, such as the time range within which the resource is shared.

>  This parameter is returned only if the principal is an Alibaba Cloud service.', example='{
    "plan":{
        "timeRangeType":"timeRange",
        "beginAtTime":"00:00",
        "timezone":"UTC+8",
        "endAtTime":"19:59"
    }
}'),
      updateTime?: string(name='UpdateTime', description='The time when the association of the entity was updated. The value of this parameter depends on the value of the AssociationType parameter:

*   If the value of `AssociationType` is `Resource`, the value of this parameter is the time when the association of the shared resource was updated.
*   If the value of `AssociationType` is `Target`, the value of this parameter is the time when the association of the principal was updated.', example='2020-12-04T09:40:41.246Z'),
    }
  ](name='ResourceShareAssociations', description='The information about the entities that are associated with the resource share.'),
}

model AssociateResourceShareResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: AssociateResourceShareResponseBody(name='body'),
}

/**
 * @summary Associates resources or principals with a resource share.
 *
 * @description This topic provides an example on how to call the API operation to associate the vSwitch `vsw-bp183p93qs667muql****` and the member `172050525300****` with the resource share `rs-6GRmdD3X****` in the `cn-hangzhou` region. After the association, the vSwitch is shared with the member.
 *
 * @param request AssociateResourceShareRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return AssociateResourceShareResponse
 */
async function associateResourceShareWithOptions(request: AssociateResourceShareRequest, runtime: Util.RuntimeOptions): AssociateResourceShareResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.permissionNames)) {
    query['PermissionNames'] = request.permissionNames;
  }
  if (!Util.isUnset(request.resourceShareId)) {
    query['ResourceShareId'] = request.resourceShareId;
  }
  if (!Util.isUnset(request.resources)) {
    query['Resources'] = request.resources;
  }
  if (!Util.isUnset(request.targetProperties)) {
    query['TargetProperties'] = request.targetProperties;
  }
  if (!Util.isUnset(request.targets)) {
    query['Targets'] = request.targets;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'AssociateResourceShare',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Associates resources or principals with a resource share.
 *
 * @description This topic provides an example on how to call the API operation to associate the vSwitch `vsw-bp183p93qs667muql****` and the member `172050525300****` with the resource share `rs-6GRmdD3X****` in the `cn-hangzhou` region. After the association, the vSwitch is shared with the member.
 *
 * @param request AssociateResourceShareRequest
 * @return AssociateResourceShareResponse
 */
async function associateResourceShare(request: AssociateResourceShareRequest): AssociateResourceShareResponse {
  var runtime = new Util.RuntimeOptions{};
  return associateResourceShareWithOptions(request, runtime);
}

model AssociateResourceSharePermissionRequest {
  permissionName?: string(name='PermissionName', description='The name of the permission.

This parameter is required.', example='AliyunRSDefaultPermissionVSwitch'),
  replace?: boolean(name='Replace', description='Specifies whether to use the specified permission to replace an existing permission. Valid values:

*   false: does not use the specified permission to replace an existing permission. This is the default value. If you set the value to false for a resource share that does not have associated permissions, the system associates the specified permission with the resource share. In a resource share, one resource type can have only one permission. If you set the value to false for a resource share that already has a permission for the resource type indicated by the specified permission, the system reports an error. This prevents you from replacing the existing permission by mistake.
*   true: uses the specified permission to replace an existing permission of the same resource type.', example='false'),
  resourceShareId?: string(name='ResourceShareId', description='The ID of the resource share.

This parameter is required.', example='rs-6GRmdD3X****'),
}

model AssociateResourceSharePermissionResponseBody = {
  requestId?: string(name='RequestId', description='The ID of the request.', example='111FB84A-60A9-403E-9067-E55D7EE95BD1'),
}

model AssociateResourceSharePermissionResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: AssociateResourceSharePermissionResponseBody(name='body'),
}

/**
 * @summary Associates permissions with a resource share.
 *
 * @description This topic provides an example on how to call the API operation to associate the `AliyunRSDefaultPermissionVSwitch` permission with the `rs-6GRmdD3X****` resource share in the `cn-hangzhou` region.
 *
 * @param request AssociateResourceSharePermissionRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return AssociateResourceSharePermissionResponse
 */
async function associateResourceSharePermissionWithOptions(request: AssociateResourceSharePermissionRequest, runtime: Util.RuntimeOptions): AssociateResourceSharePermissionResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.permissionName)) {
    query['PermissionName'] = request.permissionName;
  }
  if (!Util.isUnset(request.replace)) {
    query['Replace'] = request.replace;
  }
  if (!Util.isUnset(request.resourceShareId)) {
    query['ResourceShareId'] = request.resourceShareId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'AssociateResourceSharePermission',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Associates permissions with a resource share.
 *
 * @description This topic provides an example on how to call the API operation to associate the `AliyunRSDefaultPermissionVSwitch` permission with the `rs-6GRmdD3X****` resource share in the `cn-hangzhou` region.
 *
 * @param request AssociateResourceSharePermissionRequest
 * @return AssociateResourceSharePermissionResponse
 */
async function associateResourceSharePermission(request: AssociateResourceSharePermissionRequest): AssociateResourceSharePermissionResponse {
  var runtime = new Util.RuntimeOptions{};
  return associateResourceSharePermissionWithOptions(request, runtime);
}

model ChangeResourceGroupRequest {
  resourceGroupId?: string(name='ResourceGroupId', description='The ID of the destination resource group.

This parameter is required.', example='rg-aek2nb47ueqk***'),
  resourceId?: string(name='ResourceId', description='The ID of the resource share.

This parameter is required.', example='rs-dz3Ek1iiO***'),
  resourceRegionId?: string(name='ResourceRegionId', description='The region ID of the resource share.

This parameter is required.', example='cn-hangzhou'),
}

model ChangeResourceGroupResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='0A900114-22D3-5E9D-87A2-48E5EB5BF310'),
}

model ChangeResourceGroupResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ChangeResourceGroupResponseBody(name='body'),
}

/**
 * @summary Transfers a resource share from one resource group to another.
 *
 * @param request ChangeResourceGroupRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ChangeResourceGroupResponse
 */
async function changeResourceGroupWithOptions(request: ChangeResourceGroupRequest, runtime: Util.RuntimeOptions): ChangeResourceGroupResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.resourceGroupId)) {
    query['ResourceGroupId'] = request.resourceGroupId;
  }
  if (!Util.isUnset(request.resourceId)) {
    query['ResourceId'] = request.resourceId;
  }
  if (!Util.isUnset(request.resourceRegionId)) {
    query['ResourceRegionId'] = request.resourceRegionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ChangeResourceGroup',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Transfers a resource share from one resource group to another.
 *
 * @param request ChangeResourceGroupRequest
 * @return ChangeResourceGroupResponse
 */
async function changeResourceGroup(request: ChangeResourceGroupRequest): ChangeResourceGroupResponse {
  var runtime = new Util.RuntimeOptions{};
  return changeResourceGroupWithOptions(request, runtime);
}

model CheckSharingWithResourceDirectoryStatusResponseBody = {
  enableSharingWithRd?: boolean(name='EnableSharingWithRd', description='Indicates whether resource sharing within a resource directory is enabled. Valid values:

*   false
*   true', example='true'),
  requestId?: string(name='RequestId', description='The request ID.', example='819545D0-C97A-5DB3-BD73-A1B17E9A4BC1'),
}

model CheckSharingWithResourceDirectoryStatusResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CheckSharingWithResourceDirectoryStatusResponseBody(name='body'),
}

/**
 * @summary Checks the status of resource sharing within a resource directory.
 *
 * @param request CheckSharingWithResourceDirectoryStatusRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CheckSharingWithResourceDirectoryStatusResponse
 */
async function checkSharingWithResourceDirectoryStatusWithOptions(runtime: Util.RuntimeOptions): CheckSharingWithResourceDirectoryStatusResponse {
  var req = new OpenApi.OpenApiRequest{};
  var params = new OpenApi.Params{
    action = 'CheckSharingWithResourceDirectoryStatus',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Checks the status of resource sharing within a resource directory.
 *
 * @return CheckSharingWithResourceDirectoryStatusResponse
 */
async function checkSharingWithResourceDirectoryStatus(): CheckSharingWithResourceDirectoryStatusResponse {
  var runtime = new Util.RuntimeOptions{};
  return checkSharingWithResourceDirectoryStatusWithOptions(runtime);
}

model CreateResourceShareRequest {
  allowExternalTargets?: boolean(name='AllowExternalTargets', description='Specifies whether resources in the resource share can be shared with accounts outside the resource directory. Valid values:

*   false (default): Resources in the resource share can be shared only with accounts in the resource directory.
*   true: Resources in the resource share can be shared with both accounts in the resource directory and accounts outside the resource directory.', example='false'),
  permissionNames?: [ string ](name='PermissionNames', description='The information about the permissions. If you do not configure this parameter, the system automatically associates the default permission for the specified resource type with the resource share. For more information, see [Permission library](https://help.aliyun.com/document_detail/465474.html).'),
  resourceGroupId?: string(name='ResourceGroupId'),
  resourceShareName?: string(name='ResourceShareName', description='The name of the resource share.

The name must be 1 to 50 characters in length.

The name can contain letters, digits, periods (.), underscores (_), and hyphens (-).

This parameter is required.', example='test'),
  resources?: [ 
    {
      resourceId?: string(name='ResourceId', description='The ID of a shared resource.

Valid values of N: 1 to 5. This indicates that a maximum of five shared resources can be specified at a time.

>  `Resources.N.ResourceId` and `Resources.N.ResourceType` must be used in pairs.', example='vsw-bp183p93qs667muql****'),
      resourceType?: string(name='ResourceType', description='The type of a shared resource.

Valid values of N: 1 to 5. This indicates that a maximum of five shared resources can be specified at a time.

For more information about the types of resources that can be shared, see [Services that work with Resource Sharing](https://help.aliyun.com/document_detail/450526.html).

>  `Resources.N.ResourceId` and `Resources.N.ResourceType` must be used in pairs.', example='VSwitch'),
    }
  ](name='Resources', description='The information about the shared resources.'),
  tag?: [ 
    {
      key?: string(name='Key'),
      value?: string(name='Value'),
    }
  ](name='Tag'),
  targetProperties?: [ 
    {
      property?: string(name='Property', description='The property parameter of the principal. For example, you can specify a parameter that indicates the time range for resource sharing. Valid values of `timeRangeType`:

*   timeRange: a specific time range
*   day: all day

>  `TargetProperties.N.TargetId` and `TargetProperties.N.Property` must be used in pairs.', example='{
    "timeRange":{
        "timeRangeType":"timeRange",
        "beginAtTime":"00:00",
        "timezone":"UTC+8",
        "endAtTime":"19:59"
    }
}'),
      targetId?: string(name='TargetId', description='The ID of the principal.

>  `TargetProperties.N.TargetId` and `TargetProperties.N.Property` must be used in pairs.', example='172050525300****'),
    }
  ](name='TargetProperties', description='The properties of the principal.

>  This parameter is available only when you specify an Alibaba Cloud service as a principal.'),
  targets?: [ string ](name='Targets', description='The information about the principals.', example='172050525300****'),
}

model CreateResourceShareResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='2C3FA051-61DC-4F3E-81E9-E4830524DF4B'),
  resourceShare?: {
    allowExternalTargets?: boolean(name='AllowExternalTargets', description='Indicates whether resources in the resource share can be shared with accounts outside the resource directory. Valid values:

*   false: Resources in the resource share can be shared only with accounts in the resource directory.
*   true: Resources in the resource share can be shared with both accounts in the resource directory and accounts outside the resource directory.', example='false'),
    createTime?: string(name='CreateTime', description='The time when the resource share was created.', example='2020-12-03T08:02:22.413Z'),
    resourceShareId?: string(name='ResourceShareId', description='The ID of the resource share.', example='rs-qSkW1HBY****'),
    resourceShareName?: string(name='ResourceShareName', description='The name of the resource share.', example='test'),
    resourceShareOwner?: string(name='ResourceShareOwner', description='The owner of the resource share.', example='151266687691****'),
    resourceShareStatus?: string(name='ResourceShareStatus', description='The status of the resource share. Valid values:

*   Active: The resource share is enabled.
*   Pending: The resource share is associated with one or more resource sharing invitations that are waiting for confirmation.
*   Deleting: The resource share is being deleted.
*   Deleted: The resource share is deleted.

>  The system automatically deletes the records of resource shares in the Deleted state within 48 hours to 96 hours after you delete the resource shares.', example='Active'),
    updateTime?: string(name='UpdateTime', description='The time when the resource share was updated.', example='2020-12-03T08:02:22.413Z'),
  }(name='ResourceShare', description='The information about the resource share.'),
}

model CreateResourceShareResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateResourceShareResponseBody(name='body'),
}

/**
 * @summary Creates a resource share.
 *
 * @description Resource Sharing allows you to share your resources with one or more accounts and access the resources shared by other accounts. For more information, see [Resource Sharing overview](https://help.aliyun.com/document_detail/160622.html).
 * This topic provides an example on how to call the API operation to create a resource share named `test` in the `cn-hangzhou` region to share the vSwitch `vsw-bp183p93qs667muql****` with the member `172050525300****` in a resource directory. In this example, the management account of the resource directory is used to call this API operation.
 *
 * @param request CreateResourceShareRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateResourceShareResponse
 */
async function createResourceShareWithOptions(request: CreateResourceShareRequest, runtime: Util.RuntimeOptions): CreateResourceShareResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.allowExternalTargets)) {
    query['AllowExternalTargets'] = request.allowExternalTargets;
  }
  if (!Util.isUnset(request.permissionNames)) {
    query['PermissionNames'] = request.permissionNames;
  }
  if (!Util.isUnset(request.resourceGroupId)) {
    query['ResourceGroupId'] = request.resourceGroupId;
  }
  if (!Util.isUnset(request.resourceShareName)) {
    query['ResourceShareName'] = request.resourceShareName;
  }
  if (!Util.isUnset(request.resources)) {
    query['Resources'] = request.resources;
  }
  if (!Util.isUnset(request.tag)) {
    query['Tag'] = request.tag;
  }
  if (!Util.isUnset(request.targetProperties)) {
    query['TargetProperties'] = request.targetProperties;
  }
  if (!Util.isUnset(request.targets)) {
    query['Targets'] = request.targets;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateResourceShare',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Creates a resource share.
 *
 * @description Resource Sharing allows you to share your resources with one or more accounts and access the resources shared by other accounts. For more information, see [Resource Sharing overview](https://help.aliyun.com/document_detail/160622.html).
 * This topic provides an example on how to call the API operation to create a resource share named `test` in the `cn-hangzhou` region to share the vSwitch `vsw-bp183p93qs667muql****` with the member `172050525300****` in a resource directory. In this example, the management account of the resource directory is used to call this API operation.
 *
 * @param request CreateResourceShareRequest
 * @return CreateResourceShareResponse
 */
async function createResourceShare(request: CreateResourceShareRequest): CreateResourceShareResponse {
  var runtime = new Util.RuntimeOptions{};
  return createResourceShareWithOptions(request, runtime);
}

model DeleteResourceShareRequest {
  resourceShareId?: string(name='ResourceShareId', description='The ID of the resource share.

This parameter is required.', example='rs-qSkW1HBY****'),
}

model DeleteResourceShareResponseBody = {
  requestId?: string(name='RequestId', description='The ID of the request.', example='A627EE2A-223D-4E1F-A954-394686AEA916'),
}

model DeleteResourceShareResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteResourceShareResponseBody(name='body'),
}

/**
 * @summary 调用DeleteResourceShare删除共享单元。
 *
 * @description After a resource share is deleted, all principals in the resource share can no longer access the resources in the resource share. However, the resources are not deleted with the resource share.
 * A resource share that is deleted is in the `Deleted` state. The system deletes the record of the resource share within 48 hours to 96 hours.
 * This topic provides an example on how to call the API operation to delete the resource share `rs-qSkW1HBY****` in the `cn-hangzhou` region.
 *
 * @param request DeleteResourceShareRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteResourceShareResponse
 */
async function deleteResourceShareWithOptions(request: DeleteResourceShareRequest, runtime: Util.RuntimeOptions): DeleteResourceShareResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.resourceShareId)) {
    query['ResourceShareId'] = request.resourceShareId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteResourceShare',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 调用DeleteResourceShare删除共享单元。
 *
 * @description After a resource share is deleted, all principals in the resource share can no longer access the resources in the resource share. However, the resources are not deleted with the resource share.
 * A resource share that is deleted is in the `Deleted` state. The system deletes the record of the resource share within 48 hours to 96 hours.
 * This topic provides an example on how to call the API operation to delete the resource share `rs-qSkW1HBY****` in the `cn-hangzhou` region.
 *
 * @param request DeleteResourceShareRequest
 * @return DeleteResourceShareResponse
 */
async function deleteResourceShare(request: DeleteResourceShareRequest): DeleteResourceShareResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteResourceShareWithOptions(request, runtime);
}

model DescribeRegionsRequest {
  acceptLanguage?: string(name='AcceptLanguage', description='The supported natural language. Valid values:

*   zh-CN: Chinese
*   en-US: English', example='zh-CN'),
}

model DescribeRegionsResponseBody = {
  regions?: [ 
    {
      localName?: string(name='LocalName', description='The name of the region.', example='China (Hangzhou)'),
      regionEndpoint?: string(name='RegionEndpoint', description='The endpoint of the Resource Sharing service in the region.', example='resourcesharing.cn-hangzhou.aliyuncs.com'),
      regionId?: string(name='RegionId', description='The ID of the region.', example='cn-hangzhou'),
    }
  ](name='Regions', description='The information of the regions.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='0D64A198-5842-4570-8E26-5E540CDC84CD'),
}

model DescribeRegionsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeRegionsResponseBody(name='body'),
}

/**
 * @summary Queries the regions where the Resource Sharing service is available.
 *
 * @param request DescribeRegionsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeRegionsResponse
 */
async function describeRegionsWithOptions(request: DescribeRegionsRequest, runtime: Util.RuntimeOptions): DescribeRegionsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.acceptLanguage)) {
    query['AcceptLanguage'] = request.acceptLanguage;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeRegions',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries the regions where the Resource Sharing service is available.
 *
 * @param request DescribeRegionsRequest
 * @return DescribeRegionsResponse
 */
async function describeRegions(request: DescribeRegionsRequest): DescribeRegionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeRegionsWithOptions(request, runtime);
}

model DisassociateResourceShareRequest {
  resourceOwner?: string(name='ResourceOwner', description='The owner of the resource share. Valid values:

*   Self: The resource share belongs to the current account. This is the default value. For resource sharing within a resource directory, if you are a resource owner and you want to disassociate resources or principals from a resource share, set this parameter to Self.
*   OtherAccounts: The resource share belongs to another account. For resource sharing outside a resource directory, if you are a principal and you want to exit a resource share, set this parameter to OtherAccounts.', example='Self'),
  resourceShareId?: string(name='ResourceShareId', description='The ID of the resource share.

This parameter is required.', example='rs-6GRmdD3X****'),
  resources?: [ 
    {
      resourceId?: string(name='ResourceId', description='The ID of the shared resource.

Valid values of N: 1 to 5. This indicates that a maximum of five shared resources can be specified at a time.

>  Resources.N.ResourceId and Resources.N.ResourceType must be used in pairs.', example='vsw-bp183p93qs667muql****'),
      resourceType?: string(name='ResourceType', description='The type of a shared resource.

Valid values of N: 1 to 5. This indicates that a maximum of five shared resources can be specified at a time.

For more information about the types of resources that can be shared, see [Services that work with Resource Sharing](https://help.aliyun.com/document_detail/450526.html).

>  Resources.N.ResourceId and Resources.N.ResourceType must be used in pairs.', example='VSwitch'),
    }
  ](name='Resources', description='The information about the resources.'),
  targets?: [ string ](name='Targets', description='The information about the principals.', example='172050525300****'),
}

model DisassociateResourceShareResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='95230BC9-A8E8-4493-96BD-4F0C758E37F8'),
  resourceShareAssociations?: [ 
    {
      associationStatus?: string(name='AssociationStatus', description='The association status. Valid values:

*   Associating: The entity is being associated.
*   Associated: The entity is associated.
*   Failed: The entity fails to be associated.
*   Disassociating: The entity is being disassociated.
*   Disassociated: The entity is disassociated.

>  The system deletes the records of entities in the `Failed` or `Disassociated` state within 48 hours to 96 hours.', example='Disassociating'),
      associationStatusMessage?: string(name='AssociationStatusMessage', description='The cause of the disassociation failure.', example='The Resources is invalid.'),
      associationType?: string(name='AssociationType', description='The association type. Valid values:

*   Resource
*   Target', example='Target'),
      createTime?: string(name='CreateTime', description='The time when the disassociation of the entity was performed. The value of this parameter depends on the value of the AssociationType parameter:

*   If the value of `AssociationType` is `Resource`, the value of this parameter is the time when the resource was disassociated from the resource share.
*   If the value of `AssociationType` is `Target`, the value of this parameter is the time when the principal was disassociated from the resource share.', example='2020-12-04T09:40:41.250Z'),
      entityId?: string(name='EntityId', description='The ID of the entity. The value of this parameter depends on the value of the AssociationType parameter:

*   If the value of `AssociationType` is `Resource`, the value of this parameter is the ID of the resource.
*   If the value of `AssociationType` is `Target`, the value of this parameter is the ID of the resource directory, folder, member, or Alibaba Cloud service.', example='172050525300****'),
      entityType?: string(name='EntityType', description='The type of the entity. The value of this parameter depends on the value of the AssociationType parameter:

*   If the value of AssociationType is Resource, the value of this parameter is the type of the resource. For more information about the types of resources that can be shared, see [Services that work with Resource Sharing](https://help.aliyun.com/document_detail/450526.html).
*   If the value of AssociationType is Target, the value of this parameter is Account.', example='Account'),
      resourceShareId?: string(name='ResourceShareId', description='The ID of the resource share.', example='rs-6GRmdD3X****'),
      resourceShareName?: string(name='ResourceShareName', description='The name of the resource share.', example='test'),
      targetProperty?: string(name='TargetProperty', description='The properties of the principal, such as the time range within which the resource is shared.

>  This parameter is returned only if the principal is an Alibaba Cloud service.', example='{
    "timeRange":{
        "timeRangeType":"timeRange",
        "beginAtTime":"00:00",
        "timezone":"UTC+8",
        "endAtTime":"19:59"
    }
}'),
      updateTime?: string(name='UpdateTime', description='The time when the disassociation of the entity was updated. The value of this parameter depends on the value of the AssociationType parameter:

*   If the value of `AssociationType` is `Resource`, the value of this parameter is the time when the disassociation of the resource was updated.
*   If the value of `AssociationType` is `Target`, the value of this parameter is the time when the disassociation of the principal was updated.', example='2020-12-04T09:40:45.556Z'),
    }
  ](name='ResourceShareAssociations', description='The information about the entities that are associated with the resource share.'),
}

model DisassociateResourceShareResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DisassociateResourceShareResponseBody(name='body'),
}

/**
 * @summary Disassociates resources or principals from a resource share.
 *
 * @description *   A resource owner can call this API operation to disassociate shared resources or principals from a resource share.
 * *   If a principal does not belong to a resource directory, the principal can call this API operation to exit the resource share. For more information, see [Exit a resource share](https://help.aliyun.com/document_detail/440614.html).
 * This topic provides an example on how to use the management account of a resource directory to call the API operation to disassociate the member `172050525300****` from the resource share `rs-6GRmdD3X****` in the `cn-hangzhou` region. After the member is disassociated from the resource share, the member cannot share the resources in the resource share.
 *
 * @param request DisassociateResourceShareRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DisassociateResourceShareResponse
 */
async function disassociateResourceShareWithOptions(request: DisassociateResourceShareRequest, runtime: Util.RuntimeOptions): DisassociateResourceShareResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.resourceOwner)) {
    query['ResourceOwner'] = request.resourceOwner;
  }
  if (!Util.isUnset(request.resourceShareId)) {
    query['ResourceShareId'] = request.resourceShareId;
  }
  if (!Util.isUnset(request.resources)) {
    query['Resources'] = request.resources;
  }
  if (!Util.isUnset(request.targets)) {
    query['Targets'] = request.targets;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DisassociateResourceShare',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Disassociates resources or principals from a resource share.
 *
 * @description *   A resource owner can call this API operation to disassociate shared resources or principals from a resource share.
 * *   If a principal does not belong to a resource directory, the principal can call this API operation to exit the resource share. For more information, see [Exit a resource share](https://help.aliyun.com/document_detail/440614.html).
 * This topic provides an example on how to use the management account of a resource directory to call the API operation to disassociate the member `172050525300****` from the resource share `rs-6GRmdD3X****` in the `cn-hangzhou` region. After the member is disassociated from the resource share, the member cannot share the resources in the resource share.
 *
 * @param request DisassociateResourceShareRequest
 * @return DisassociateResourceShareResponse
 */
async function disassociateResourceShare(request: DisassociateResourceShareRequest): DisassociateResourceShareResponse {
  var runtime = new Util.RuntimeOptions{};
  return disassociateResourceShareWithOptions(request, runtime);
}

model DisassociateResourceSharePermissionRequest {
  permissionName?: string(name='PermissionName', description='The name of the permission. For more information, see [Permission library](https://help.aliyun.com/document_detail/465474.html).

This parameter is required.', example='AliyunRSDefaultPermissionVSwitch'),
  resourceShareId?: string(name='ResourceShareId', description='The ID of the resource share.

This parameter is required.', example='rs-6GRmdD3X****'),
}

model DisassociateResourceSharePermissionResponseBody = {
  requestId?: string(name='RequestId', description='The ID of the request.', example='111FB84A-60A9-403E-9067-E55D7EE95BD1'),
}

model DisassociateResourceSharePermissionResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DisassociateResourceSharePermissionResponseBody(name='body'),
}

/**
 * @summary Disassociates a permission from a resource share. You can disassociate a permission from a resource share only if the resource share does not contain resources of the type indicated by the permission.
 *
 * @description This topic provides an example on how to call the API operation to disassociate the `AliyunRSDefaultPermissionVSwitch` permission from the `rs-6GRmdD3X****` resource share in the `cn-hangzhou` region.
 *
 * @param request DisassociateResourceSharePermissionRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DisassociateResourceSharePermissionResponse
 */
async function disassociateResourceSharePermissionWithOptions(request: DisassociateResourceSharePermissionRequest, runtime: Util.RuntimeOptions): DisassociateResourceSharePermissionResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.permissionName)) {
    query['PermissionName'] = request.permissionName;
  }
  if (!Util.isUnset(request.resourceShareId)) {
    query['ResourceShareId'] = request.resourceShareId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DisassociateResourceSharePermission',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Disassociates a permission from a resource share. You can disassociate a permission from a resource share only if the resource share does not contain resources of the type indicated by the permission.
 *
 * @description This topic provides an example on how to call the API operation to disassociate the `AliyunRSDefaultPermissionVSwitch` permission from the `rs-6GRmdD3X****` resource share in the `cn-hangzhou` region.
 *
 * @param request DisassociateResourceSharePermissionRequest
 * @return DisassociateResourceSharePermissionResponse
 */
async function disassociateResourceSharePermission(request: DisassociateResourceSharePermissionRequest): DisassociateResourceSharePermissionResponse {
  var runtime = new Util.RuntimeOptions{};
  return disassociateResourceSharePermissionWithOptions(request, runtime);
}

model EnableSharingWithResourceDirectoryResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='2F23CFB6-A721-4E90-AC1E-0E30FA8B45DA'),
}

model EnableSharingWithResourceDirectoryResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: EnableSharingWithResourceDirectoryResponseBody(name='body'),
}

/**
 * @summary Enables resource sharing for a resource directory.
 *
 * @description You can share your resources with all members in your resource directory, all members in a specific folder in your resource directory, or a specific member in your resource directory as a resource owner only after you enable resource sharing for your resource directory.
 * You can call this API operation only by using the management account of your resource directory or a RAM user or RAM role to which the required permissions are granted within the management account.
 *
 * @param request EnableSharingWithResourceDirectoryRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return EnableSharingWithResourceDirectoryResponse
 */
async function enableSharingWithResourceDirectoryWithOptions(runtime: Util.RuntimeOptions): EnableSharingWithResourceDirectoryResponse {
  var req = new OpenApi.OpenApiRequest{};
  var params = new OpenApi.Params{
    action = 'EnableSharingWithResourceDirectory',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Enables resource sharing for a resource directory.
 *
 * @description You can share your resources with all members in your resource directory, all members in a specific folder in your resource directory, or a specific member in your resource directory as a resource owner only after you enable resource sharing for your resource directory.
 * You can call this API operation only by using the management account of your resource directory or a RAM user or RAM role to which the required permissions are granted within the management account.
 *
 * @return EnableSharingWithResourceDirectoryResponse
 */
async function enableSharingWithResourceDirectory(): EnableSharingWithResourceDirectoryResponse {
  var runtime = new Util.RuntimeOptions{};
  return enableSharingWithResourceDirectoryWithOptions(runtime);
}

model GetPermissionRequest {
  permissionName?: string(name='PermissionName', description='The name of the permission.

This parameter is required.', example='AliyunRSDefaultPermissionVSwitch'),
  permissionVersion?: string(name='PermissionVersion', description='The version of the permission.', example='v1'),
}

model GetPermissionResponseBody = {
  permission?: {
    createTime?: string(name='CreateTime', description='The creation time.', example='2020-12-07T07:39:01.818Z'),
    defaultPermission?: boolean(name='DefaultPermission', description='Indicates whether the permission is the default permission. Valid values:

*   false: The permission is not the default permission.
*   true: The permission is the default permission.', example='true'),
    defaultVersion?: boolean(name='DefaultVersion', description='Indicates whether the version is the default version. Valid values:

*   false: The version is not the default version.
*   true: The version is the default version.', example='true'),
    permission?: string(name='Permission', description='The document of the policy related to the permission.', example='{"Effect":"Allow","Action":["vpc:DescribeVSwitches","vpc:DescribeVSwitchAttributes"]}'),
    permissionName?: string(name='PermissionName', description='The name of the permission.', example='AliyunRSDefaultPermissionVSwitch'),
    permissionVersion?: string(name='PermissionVersion', description='The version of the permission.', example='v1'),
    resourceType?: string(name='ResourceType', description='The type of the shared resources.

For more information about the types of resources that can be shared, see [Services that work with Resource Sharing](https://help.aliyun.com/document_detail/450526.html).', example='VSwitch'),
    updateTime?: string(name='UpdateTime', description='The update time.', example='2020-12-07T07:39:01.818Z'),
  }(name='Permission', description='The information about the permission.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='2F23CFB6-A721-4E90-AC1E-0E30FA8B45DA'),
}

model GetPermissionResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetPermissionResponseBody(name='body'),
}

/**
 * @summary Queries the information about a permission.
 *
 * @description This topic provides an example on how to call the API operation to query the information about the `AliyunRSDefaultPermissionVSwitch` permission whose version is `v1` in the `cn-hangzhou` region.
 *
 * @param request GetPermissionRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetPermissionResponse
 */
async function getPermissionWithOptions(request: GetPermissionRequest, runtime: Util.RuntimeOptions): GetPermissionResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.permissionName)) {
    query['PermissionName'] = request.permissionName;
  }
  if (!Util.isUnset(request.permissionVersion)) {
    query['PermissionVersion'] = request.permissionVersion;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetPermission',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries the information about a permission.
 *
 * @description This topic provides an example on how to call the API operation to query the information about the `AliyunRSDefaultPermissionVSwitch` permission whose version is `v1` in the `cn-hangzhou` region.
 *
 * @param request GetPermissionRequest
 * @return GetPermissionResponse
 */
async function getPermission(request: GetPermissionRequest): GetPermissionResponse {
  var runtime = new Util.RuntimeOptions{};
  return getPermissionWithOptions(request, runtime);
}

model ListPermissionVersionsRequest {
  maxResults?: int32(name='MaxResults', description='The maximum number of entries to return for a single request.

Valid values: 1 to 100. Default value: 20.', example='20'),
  nextToken?: string(name='NextToken', description='The `token` that is used to initiate the next request. If the response of the current request is truncated, you can use the token to initiate another request and obtain the remaining records.', example='TGlzdFJlc291cm****'),
  permissionName?: string(name='PermissionName', description='The name of the permission.

This parameter is required.', example='AliyunRSDefaultPermissionVSwitch'),
}

model ListPermissionVersionsResponseBody = {
  nextToken?: string(name='NextToken', description='The token that is used to initiate the next request. If the response of the current request is truncated, you can use the token to initiate another request and obtain the remaining records.', example='TGlzdFJlc291cm****'),
  permissions?: [ 
    {
      createTime?: string(name='CreateTime', description='The creation time.', example='2020-12-07T07:39:01.818Z'),
      defaultPermission?: boolean(name='DefaultPermission', description='Indicates whether the permission is the default permission. Valid values:

*   false: The permission is not the default permission.
*   true: The permission is the default permission.', example='true'),
      defaultVersion?: boolean(name='DefaultVersion', description='Indicates whether the version is the default version. Valid values:

*   false: The version is not the default version.
*   true: The version is the default version.', example='true'),
      permissionName?: string(name='PermissionName', description='The name of the permission.', example='AliyunRSDefaultPermissionVSwitch'),
      permissionVersion?: string(name='PermissionVersion', description='The version of the permission.', example='v1'),
      resourceType?: string(name='ResourceType', description='The type of the shared resources.

For more information about the types of resources that can be shared, see [Services that work with Resource Sharing](https://help.aliyun.com/document_detail/450526.html).', example='VSwitch'),
      updateTime?: string(name='UpdateTime', description='The update time.', example='2020-12-07T07:39:01.818Z'),
    }
  ](name='Permissions', description='The information about the permission.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='04677DCA-7C33-464B-8811-1B1DA3C3D197'),
}

model ListPermissionVersionsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListPermissionVersionsResponseBody(name='body'),
}

/**
 * @summary Queries the versions of a permission.
 *
 * @description This topic provides an example on how to call the API operation to query the versions of the `AliyunRSDefaultPermissionVSwitch` permission in the `cn-hangzhou` region.
 *
 * @param request ListPermissionVersionsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListPermissionVersionsResponse
 */
async function listPermissionVersionsWithOptions(request: ListPermissionVersionsRequest, runtime: Util.RuntimeOptions): ListPermissionVersionsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.maxResults)) {
    query['MaxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.permissionName)) {
    query['PermissionName'] = request.permissionName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListPermissionVersions',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries the versions of a permission.
 *
 * @description This topic provides an example on how to call the API operation to query the versions of the `AliyunRSDefaultPermissionVSwitch` permission in the `cn-hangzhou` region.
 *
 * @param request ListPermissionVersionsRequest
 * @return ListPermissionVersionsResponse
 */
async function listPermissionVersions(request: ListPermissionVersionsRequest): ListPermissionVersionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listPermissionVersionsWithOptions(request, runtime);
}

model ListPermissionsRequest {
  maxResults?: int32(name='MaxResults', description='The maximum number of entries to return for a single request.

Valid values: 1 to 100. Default value: 20.', example='20'),
  nextToken?: string(name='NextToken', description='The `token` that is used to initiate the next request. If the response of the current request is truncated, you can use the token to initiate another request and obtain the remaining records.', example='TGlzdFJlc291cm****'),
  resourceType?: string(name='ResourceType', description='The type of the shared resources.

For more information about the types of resources that can be shared, see [Services that work with Resource Sharing](https://help.aliyun.com/document_detail/450526.html).', example='VSwitch'),
}

model ListPermissionsResponseBody = {
  nextToken?: string(name='NextToken', description='The token that is used to initiate the next request. If the response of the current request is truncated, you can use the token to initiate another request and obtain the remaining records.', example='TGlzdFJlc291cm****'),
  permissions?: [ 
    {
      createTime?: string(name='CreateTime', description='The creation time.', example='2020-12-07T07:39:01.818Z'),
      defaultPermission?: boolean(name='DefaultPermission', description='Indicates whether the permission is the default permission. Valid values:

*   false: The permission is not the default permission.
*   true: The permission is the default permission.', example='true'),
      defaultVersion?: boolean(name='DefaultVersion', description='Indicates whether the version is the default version. Valid values:

*   false: The version is not the default version.
*   true: The version is the default version.', example='true'),
      permissionName?: string(name='PermissionName', description='The name of the permission.', example='AliyunRSDefaultPermissionVSwitch'),
      permissionVersion?: string(name='PermissionVersion', description='The version of the permission.', example='v1'),
      resourceType?: string(name='ResourceType', description='The type of the shared resources.

For more information about the types of resources that can be shared, see [Services that work with Resource Sharing](https://help.aliyun.com/document_detail/450526.html).', example='VSwitch'),
      updateTime?: string(name='UpdateTime', description='The update time.', example='2020-12-07T07:39:01.818Z'),
    }
  ](name='Permissions', description='The information about the permission.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='04677DCA-7C33-464B-8811-1B1DA3C3D197'),
}

model ListPermissionsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListPermissionsResponseBody(name='body'),
}

/**
 * @summary Queries the information about the default permission.
 *
 * @description This topic provides an example on how to call the API operation to query the information about the default permission for the `VSwitch` resource type in the `cn-hangzhou` region.
 *
 * @param request ListPermissionsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListPermissionsResponse
 */
async function listPermissionsWithOptions(request: ListPermissionsRequest, runtime: Util.RuntimeOptions): ListPermissionsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.maxResults)) {
    query['MaxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListPermissions',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries the information about the default permission.
 *
 * @description This topic provides an example on how to call the API operation to query the information about the default permission for the `VSwitch` resource type in the `cn-hangzhou` region.
 *
 * @param request ListPermissionsRequest
 * @return ListPermissionsResponse
 */
async function listPermissions(request: ListPermissionsRequest): ListPermissionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listPermissionsWithOptions(request, runtime);
}

model ListResourceShareAssociationsRequest {
  associationStatus?: string(name='AssociationStatus', description='The association status. Valid values:

*   Associating: The entity is being associated.
*   Associated: The entity is associated.
*   Failed: The entity fails to be associated.
*   Disassociating: The entity is being disassociated.
*   Disassociated: The entity is disassociated.

>  The system deletes the records of entities in the `Failed` or `Disassociated` state within 48 hours to 96 hours.', example='Associated'),
  associationType?: string(name='AssociationType', description='The association type. Valid values:

*   Resource
*   Target

This parameter is required.', example='Resource'),
  maxResults?: int32(name='MaxResults', description='The maximum number of entries to return for a single request.

Valid values: 1 to 100. Default value: 20.', example='20'),
  nextToken?: string(name='NextToken', description='The `token` that is used to initiate the next request if the response of the current request is truncated. You can use the token to initiate another request and obtain the remaining records.', example='TGlzdFJlc291cm****'),
  resourceId?: string(name='ResourceId', description='The ID of the resource.

>  This parameter is unavailable if you set the `AssociationType` parameter to `Target`.', example='vsw-bp183p93qs667muql****'),
  resourceShareIds?: [ string ](name='ResourceShareIds', description='The IDs of the resource shares.

Valid values of N: 1 to 5. This indicates that a maximum of five resource shares can be specified at a time.', example='rs-6GRmdD3X****'),
  target?: string(name='Target', description='The ID of the principal.

>  This parameter is unavailable if you set the `AssociationType` parameter to `Resource`.', example='172050525300****'),
}

model ListResourceShareAssociationsResponseBody = {
  nextToken?: string(name='NextToken', description='The `token` that is used to initiate the next request if the response of the current request is truncated. You can use the token to initiate another request and obtain the remaining records.', example='TGlzdFJlc291cm****'),
  requestId?: string(name='RequestId', description='The request ID.', example='11BA57B5-7301-4E2F-BBA5-2AE4C2F4FCDB'),
  resourceShareAssociations?: [ 
    {
      associationFailedDetails?: [ 
        {
          associateType?: string(name='AssociateType', description='This parameter is deprecated. The OperationType parameter is used instead.', example='None'),
          entityId?: string(name='EntityId', description='The ID of the entity. The value of this parameter depends on the value of the AssociationType parameter:

*   If the value of AssociationType is Resource, the value of this parameter is the ID of the principal.
*   If the value of AssociationType is Target, the value of this parameter is the ID of the resource.', example='172050525300****'),
          entityType?: string(name='EntityType', description='The type of the entity. The value of this parameter depends on the value of the AssociationType parameter:

*   If the value of AssociationType is Resource, the value of this parameter is the type of the resource. For information about the types of resources that can be shared, see Services that work with Resource Sharing.
*   If the value of AssociationType is Target, the value of this parameter is `ResourceDirectory`, `Folder`, `Account`, or `Service`.', example='Account'),
          failureDescription?: string(name='FailureDescription', description='The failure description.', example='You cannot access the specified resource at this time.'),
          failureReason?: string(name='FailureReason', description='The failure cause. Valid values:

*   Unavailable: The resource does not exist.
*   LimitExceeded: The number of principals for the resource exceeds the upper limit.
*   ZonalResourceInaccessible: The resource is unavailable in this region.
*   InternalError: An internal error occurred.
*   UnsupportedOperation: You cannot perform this operation.', example='Unavailable'),
          operationType?: string(name='OperationType', description='The operation type. Valid values:

*   Associate
*   Disassociate', example='Associate'),
          status?: string(name='Status', description='This parameter is deprecated. The FailureReason parameter is used instead.', example='None'),
          statusMessage?: string(name='StatusMessage', description='This parameter is deprecated. The FailureDescription parameter is used instead.', example='None'),
        }
      ](name='AssociationFailedDetails', description='The information about the failure.'),
      associationStatus?: string(name='AssociationStatus', description='The association status. Valid values:

*   Associating: The entity is being associated.
*   Associated: The entity is associated.
*   Failed: The entity fails to be associated.
*   Disassociating: The entity is being disassociated.
*   Disassociated: The entity is disassociated.

>  The system deletes the records of entities in the `Failed` or `Disassociated` state within 48 hours to 96 hours.', example='Associated'),
      associationStatusMessage?: string(name='AssociationStatusMessage', description='The cause of the association failure.', example='The reason for the association failure.'),
      associationType?: string(name='AssociationType', description='The association type. Valid values:

*   Resource
*   Target', example='Resource'),
      createTime?: string(name='CreateTime', description='The time when the association of the entity was created. The value of this parameter depends on the value of the AssociationType parameter:

*   If the value of `AssociationType` is `Resource`, the value of this parameter is the time when the shared resource was associated with or disassociated from the resource share.
*   If the value of `AssociationType` is `Target`, the value of this parameter is the time when the principal was associated with or disassociated from the resource share.', example='2020-12-07T07:39:01.818Z'),
      entityId?: string(name='EntityId', description='The ID of the entity. The value of this parameter depends on the value of the AssociationType parameter:

*   If the value of `AssociationType` is `Resource`, the value of this parameter is the ID of the resource.
*   If the value of `AssociationType` is `Target`, the value of this parameter is the ID of the principal.', example='vsw-bp1upw03qyz8n7us9****'),
      entityType?: string(name='EntityType', description='The type of the entity. The value of this parameter depends on the value of the AssociationType parameter:

*   If the value of AssociationType is Resource, the value of this parameter is the type of the resource. For information about the types of resources that can be shared, see [Services that work with Resource Sharing](https://help.aliyun.com/document_detail/450526.html).
*   If the value of AssociationType is Target, the value of this parameter is `Account`.', example='VSwitch'),
      external?: boolean(name='External', description='Indicates whether the principal is outside the resource directory. Valid values:

*   true
*   false', example='false'),
      resourceShareId?: string(name='ResourceShareId', description='The ID of the resource share.', example='rs-6GRmdD3X****'),
      resourceShareName?: string(name='ResourceShareName', description='The name of the resource share.', example='example'),
      targetProperty?: string(name='TargetProperty', description='The properties of the principal, such as the time range within which the resource is shared. Valid values of `timeRangeType`:

*   timeRange: a specific time range
*   day: all day

>  This parameter is returned only if the principal is an Alibaba Cloud service.', example='{
    "timeRange":{
        "timeRangeType":"timeRange",
        "beginAtTime":"00:00",
        "timezone":"UTC+8",
        "endAtTime":"19:59"
    }
}'),
      updateTime?: string(name='UpdateTime', description='The time when the association of the entity was updated. The value of this parameter depends on the value of the AssociationType parameter:

*   If the value of `AssociationType` is `Resource`, the value of this parameter is the time when the association of the shared resource was updated.
*   If the value of `AssociationType` is `Target`, the value of this parameter is the time when the association of the principal was updated.', example='2020-12-07T07:39:02.920Z'),
    }
  ](name='ResourceShareAssociations', description='The information of the entities.'),
}

model ListResourceShareAssociationsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListResourceShareAssociationsResponseBody(name='body'),
}

/**
 * @summary Queries the association records of resource shares.
 *
 * @description This topic provides an example on how to call the API operation to query the association records of the resource shares that are created by using the current Alibaba Cloud account in the `cn-hangzhou` region. The response shows the following records:
 * *   The resource `vsw-bp1upw03qyz8n7us9****` of the `VSwitch` type has been associated with the resource share `rs-6GRmdD3X****`. The resource is in the `Associated` state. This indicates that the resource is being shared.
 * *   The resource `vsw-bp183p93qs667muql****` of the `VSwitch` type has been disassociated from the resource share `rs-6GRmdD3X****`. The resource is in the `Disassociated` state. This indicates that the sharing of the resource is stopped.
 *
 * @param request ListResourceShareAssociationsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListResourceShareAssociationsResponse
 */
async function listResourceShareAssociationsWithOptions(request: ListResourceShareAssociationsRequest, runtime: Util.RuntimeOptions): ListResourceShareAssociationsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.associationStatus)) {
    query['AssociationStatus'] = request.associationStatus;
  }
  if (!Util.isUnset(request.associationType)) {
    query['AssociationType'] = request.associationType;
  }
  if (!Util.isUnset(request.maxResults)) {
    query['MaxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.resourceId)) {
    query['ResourceId'] = request.resourceId;
  }
  if (!Util.isUnset(request.resourceShareIds)) {
    query['ResourceShareIds'] = request.resourceShareIds;
  }
  if (!Util.isUnset(request.target)) {
    query['Target'] = request.target;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListResourceShareAssociations',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries the association records of resource shares.
 *
 * @description This topic provides an example on how to call the API operation to query the association records of the resource shares that are created by using the current Alibaba Cloud account in the `cn-hangzhou` region. The response shows the following records:
 * *   The resource `vsw-bp1upw03qyz8n7us9****` of the `VSwitch` type has been associated with the resource share `rs-6GRmdD3X****`. The resource is in the `Associated` state. This indicates that the resource is being shared.
 * *   The resource `vsw-bp183p93qs667muql****` of the `VSwitch` type has been disassociated from the resource share `rs-6GRmdD3X****`. The resource is in the `Disassociated` state. This indicates that the sharing of the resource is stopped.
 *
 * @param request ListResourceShareAssociationsRequest
 * @return ListResourceShareAssociationsResponse
 */
async function listResourceShareAssociations(request: ListResourceShareAssociationsRequest): ListResourceShareAssociationsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listResourceShareAssociationsWithOptions(request, runtime);
}

model ListResourceShareInvitationsRequest {
  maxResults?: int32(name='MaxResults', description='The maximum number of entries to return for a single request.

Valid values: 1 to 100. Default value: 20.', example='20'),
  nextToken?: string(name='NextToken', description='The pagination token that is used in the next request to retrieve a new page of results. You do not need to specify this parameter for the first request. You must specify the token that is obtained from the previous query as the value of `NextToken`.', example='TGlzdFJlc291cm****'),
  resourceShareIds?: [ string ](name='ResourceShareIds', description='The IDs of the resource shares.'),
  resourceShareInvitationIds?: [ string ](name='ResourceShareInvitationIds', description='The IDs of the resource sharing invitations.'),
}

model ListResourceShareInvitationsResponseBody = {
  nextToken?: string(name='NextToken', description='The pagination token that is used in the next request to retrieve a new page of results. You do not need to specify this parameter for the first request. You must specify the token that is obtained from the previous query as the value of `NextToken`.', example='TGlzdFJlc291cm****'),
  requestId?: string(name='RequestId', description='The request ID.', example='30EC8328-1BDE-51D5-BFAB-039508BD91A1'),
  resourceShareInvitations?: [ 
    {
      createTime?: string(name='CreateTime', description='The time when the invitation was created. The time is displayed in UTC.', example='2022-08-18T05:36:45.024Z'),
      invitationFailedDetails?: [ 
        {
          associateType?: string(name='AssociateType', description='This parameter is deprecated. The OperationType parameter is used instead.', example='Associate'),
          failureDescription?: string(name='FailureDescription', description='The failure description.', example='You cannot access the specified resource at this time.'),
          failureReason?: string(name='FailureReason', description='The failure cause. Valid values:

*   Unavailable: The resource cannot be shared.
*   LimitExceeded: The number of shared resources within the Alibaba Cloud account exceeds the upper limit.
*   ZonalResourceInaccessible: The resource is unavailable in this region.
*   InternalError: An internal error occurred during the check.
*   UnsupportedOperation: You cannot perform this operation.', example='Unavailable'),
          operationType?: string(name='OperationType', description='The operation type. Valid values:

*   Associate
*   Disassociate', example='Associate'),
          resourceId?: string(name='ResourceId', description='The ID of the shared resource.', example='s-7xvh46nx5oqlre0wv***'),
          resourceType?: string(name='ResourceType', description='The type of the shared resource.

For more information about the types of resources that can be shared, see [Services that work with Resource Sharing](https://help.aliyun.com/document_detail/450526.html).', example='Snapshot'),
          status?: string(name='Status', description='This parameter is deprecated. The FailureReason parameter is used instead.', example='Unavailable'),
          statusMessage?: string(name='StatusMessage', description='This parameter is deprecated. The FailureDescription parameter is used instead.', example='You cannot access the specified resource at this time.'),
        }
      ](name='InvitationFailedDetails', description='The information about the failure.'),
      receiverAccountId?: string(name='ReceiverAccountId', description='The Alibaba Cloud account ID of the invitee.', example='134254031178****'),
      resourceShareId?: string(name='ResourceShareId', description='The ID of the resource share.', example='rs-ysGRci9z****'),
      resourceShareInvitationId?: string(name='ResourceShareInvitationId', description='The ID of the invitation.', example='i-p6eRytrkjVvM****'),
      resourceShareName?: string(name='ResourceShareName', description='The name of the resource share.', example='example'),
      senderAccountId?: string(name='SenderAccountId', description='The Alibaba Cloud account ID of the inviter.', example='151266687691****'),
      status?: string(name='Status', description='The status of the invitation. Valid values:

*   Pending
*   Accepted
*   Cancelled
*   Rejected
*   Expired
*   AcceptFailed', example='Pending'),
    }
  ](name='ResourceShareInvitations', description='The information about the resource sharing invitations.'),
}

model ListResourceShareInvitationsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListResourceShareInvitationsResponseBody(name='body'),
}

/**
 * @summary Queries the resource sharing invitations that are received.
 *
 * @description ### [](#)
 * This topic provides an example on how to call the API operation to query the resource sharing invitations that are received by the current account in the `cn-hangzhou` region. The response shows that one invitation is received by the current account and is waiting for confirmation.
 *
 * @param request ListResourceShareInvitationsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListResourceShareInvitationsResponse
 */
async function listResourceShareInvitationsWithOptions(request: ListResourceShareInvitationsRequest, runtime: Util.RuntimeOptions): ListResourceShareInvitationsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.maxResults)) {
    query['MaxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.resourceShareIds)) {
    query['ResourceShareIds'] = request.resourceShareIds;
  }
  if (!Util.isUnset(request.resourceShareInvitationIds)) {
    query['ResourceShareInvitationIds'] = request.resourceShareInvitationIds;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListResourceShareInvitations',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries the resource sharing invitations that are received.
 *
 * @description ### [](#)
 * This topic provides an example on how to call the API operation to query the resource sharing invitations that are received by the current account in the `cn-hangzhou` region. The response shows that one invitation is received by the current account and is waiting for confirmation.
 *
 * @param request ListResourceShareInvitationsRequest
 * @return ListResourceShareInvitationsResponse
 */
async function listResourceShareInvitations(request: ListResourceShareInvitationsRequest): ListResourceShareInvitationsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listResourceShareInvitationsWithOptions(request, runtime);
}

model ListResourceSharePermissionsRequest {
  maxResults?: int32(name='MaxResults', description='The maximum number of entries to return for a single request.

Valid values: 1 to 100. Default value: 20.', example='20'),
  nextToken?: string(name='NextToken', description='The `token` that is used to initiate the next request. If the response of the current request is truncated, you can use the token to initiate another request and obtain the remaining records.', example='TGlzdFJlc291cm****'),
  resourceOwner?: string(name='ResourceOwner', description='The owner of the resource share. Valid values:

*   Self: the current account
*   OtherAccounts: an account other than the current account

This parameter is required.', example='Self'),
  resourceShareId?: string(name='ResourceShareId', description='The ID of the resource share.

This parameter is required.', example='rs-6GRmdD3X****'),
}

model ListResourceSharePermissionsResponseBody = {
  nextToken?: string(name='NextToken', description='The `token` that is used to initiate the next request. If the response of the current request is truncated, you can use the token to initiate another request and obtain the remaining records.', example='TGlzdFJlc291cm****'),
  permissions?: [ 
    {
      createTime?: string(name='CreateTime', description='The creation time.', example='2020-12-07T07:39:01.818Z'),
      defaultPermission?: boolean(name='DefaultPermission', description='Indicates whether the permission is the default permission. Valid values:

*   false: The permission is not the default permission.
*   true: The permission is the default permission.', example='true'),
      defaultVersion?: boolean(name='DefaultVersion', description='Indicates whether the version is the default version. Valid values:

*   false: The version is not the default version.
*   true: The version is the default version.', example='true'),
      permissionName?: string(name='PermissionName', description='The name of the permission.', example='AliyunRSDefaultPermissionVSwitch'),
      permissionVersion?: string(name='PermissionVersion', description='The version of the permission.', example='v1'),
      resourceType?: string(name='ResourceType', description='The type of the shared resources.

For more information about the types of resources that can be shared, see [Services that work with Resource Sharing](https://help.aliyun.com/document_detail/450526.html).', example='VSwitch'),
      updateTime?: string(name='UpdateTime', description='The update time.', example='2020-12-07T07:39:01.818Z'),
    }
  ](name='Permissions', description='The information about the permissions.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='2F23CFB6-A721-4E90-AC1E-0E30FA8B45DA'),
}

model ListResourceSharePermissionsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListResourceSharePermissionsResponseBody(name='body'),
}

/**
 * @summary Queries the permissions that are associated with a resource share.
 *
 * @description This topic provides an example on how to call the API operation to query the permissions that are associated with the resource share created by using the current Alibaba Cloud account in the `cn-hangzhou` region.
 *
 * @param request ListResourceSharePermissionsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListResourceSharePermissionsResponse
 */
async function listResourceSharePermissionsWithOptions(request: ListResourceSharePermissionsRequest, runtime: Util.RuntimeOptions): ListResourceSharePermissionsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.maxResults)) {
    query['MaxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.resourceOwner)) {
    query['ResourceOwner'] = request.resourceOwner;
  }
  if (!Util.isUnset(request.resourceShareId)) {
    query['ResourceShareId'] = request.resourceShareId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListResourceSharePermissions',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries the permissions that are associated with a resource share.
 *
 * @description This topic provides an example on how to call the API operation to query the permissions that are associated with the resource share created by using the current Alibaba Cloud account in the `cn-hangzhou` region.
 *
 * @param request ListResourceSharePermissionsRequest
 * @return ListResourceSharePermissionsResponse
 */
async function listResourceSharePermissions(request: ListResourceSharePermissionsRequest): ListResourceSharePermissionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listResourceSharePermissionsWithOptions(request, runtime);
}

model ListResourceSharesRequest {
  maxResults?: int32(name='MaxResults', description='The maximum number of entries to return for a single request.

Valid values: 1 to 100. Default value: 20.', example='20'),
  nextToken?: string(name='NextToken', description='The `token` that is used to initiate the next request. If the response of the current request is truncated, you can use the token to initiate another request and obtain the remaining records.', example='TGlzdFJlc291cm****'),
  permissionName?: string(name='PermissionName', description='The name of the permission. For more information, see [Permission library](https://help.aliyun.com/document_detail/465474.html).', example='AliyunRSDefaultPermissionVSwitch'),
  resourceGroupId?: string(name='ResourceGroupId'),
  resourceOwner?: string(name='ResourceOwner', description='The owner of the resource shares. Valid values:

*   Self: the current account
*   OtherAccounts: an account other than the current account

This parameter is required.', example='Self'),
  resourceShareIds?: [ string ](name='ResourceShareIds', description='The ID of a resource share.', example='rs-PqysnzIj****'),
  resourceShareName?: string(name='ResourceShareName', description='The name of the resource share.', example='test'),
  resourceShareStatus?: string(name='ResourceShareStatus', description='The status of the resource share. Valid values:

*   Active: The resource share is enabled.
*   Pending: The resource share is associated with one or more resource sharing invitations that are waiting for confirmation.
*   Deleting: The resource share is being deleted.
*   Deleted: The resource share is deleted.

>  The system deletes the records of resource shares in the Deleted state within 48 hours to 96 hours after you delete the resource shares.', example='Active'),
  tag?: [ 
    {
      key?: string(name='Key'),
      value?: string(name='Value'),
    }
  ](name='Tag'),
}

model ListResourceSharesResponseBody = {
  nextToken?: string(name='NextToken', description='The `token` that is used to initiate the next request. If the response of the current request is truncated, you can use the token to initiate another request and obtain the remaining records.', example='TGlzdFJlc291cm****'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='2F23CFB6-A721-4E90-AC1E-0E30FA8B45DA'),
  resourceShares?: [ 
    {
      allowExternalTargets?: boolean(name='AllowExternalTargets', description='Indicates whether resources in the resource share can be shared with accounts outside the resource directory. Valid values:

*   false: Resources in the resource share can be shared only with accounts in the resource directory.
*   true: Resources in the resource share can be shared with both accounts in the resource directory and accounts outside the resource directory.', example='false'),
      createTime?: string(name='CreateTime', description='The time when the resource share was created.', example='2020-12-03T02:20:31.292Z'),
      resourceGroupId?: string(name='ResourceGroupId'),
      resourceShareId?: string(name='ResourceShareId', description='The ID of the resource share.', example='rs-PqysnzIj****'),
      resourceShareName?: string(name='ResourceShareName', description='The name of the resource share.', example='test'),
      resourceShareOwner?: string(name='ResourceShareOwner', description='The owner of the resource share.', example='151266687691****'),
      resourceShareStatus?: string(name='ResourceShareStatus', description='The status of the resource share. Valid values:

*   Active: The resource share is enabled.
*   Pending: The resource share is associated with one or more resource sharing invitations that are waiting for confirmation.
*   Deleting: The resource share is being deleted.
*   Deleted: The resource share is deleted.

>  The system deletes the records of resource shares in the Deleted state within 48 hours to 96 hours after you delete the resource shares.', example='Active'),
      tags?: [ 
        {
          key?: string(name='Key'),
          value?: string(name='Value'),
        }
      ](name='Tags'),
      updateTime?: string(name='UpdateTime', description='The time when the resource share was updated.', example='2020-12-03T08:01:43.638Z'),
    }
  ](name='ResourceShares', description='The information of the resource shares.'),
}

model ListResourceSharesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListResourceSharesResponseBody(name='body'),
}

/**
 * @summary Queries resource shares.
 *
 * @description This topic provides an example on how to call the API operation to query the resource shares that are created by using the current Alibaba Cloud account in the `cn-hangzhou` region. The response shows that the following resource shares are created by using the account whose ID is `151266687691****`:
 * *   `rs-hX9wC5jO****`, which is in the `Deleted` state
 * *   `rs-PqysnzIj****`, which is in the `Active` state
 *
 * @param request ListResourceSharesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListResourceSharesResponse
 */
async function listResourceSharesWithOptions(request: ListResourceSharesRequest, runtime: Util.RuntimeOptions): ListResourceSharesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.maxResults)) {
    query['MaxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.permissionName)) {
    query['PermissionName'] = request.permissionName;
  }
  if (!Util.isUnset(request.resourceGroupId)) {
    query['ResourceGroupId'] = request.resourceGroupId;
  }
  if (!Util.isUnset(request.resourceOwner)) {
    query['ResourceOwner'] = request.resourceOwner;
  }
  if (!Util.isUnset(request.resourceShareIds)) {
    query['ResourceShareIds'] = request.resourceShareIds;
  }
  if (!Util.isUnset(request.resourceShareName)) {
    query['ResourceShareName'] = request.resourceShareName;
  }
  if (!Util.isUnset(request.resourceShareStatus)) {
    query['ResourceShareStatus'] = request.resourceShareStatus;
  }
  if (!Util.isUnset(request.tag)) {
    query['Tag'] = request.tag;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListResourceShares',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries resource shares.
 *
 * @description This topic provides an example on how to call the API operation to query the resource shares that are created by using the current Alibaba Cloud account in the `cn-hangzhou` region. The response shows that the following resource shares are created by using the account whose ID is `151266687691****`:
 * *   `rs-hX9wC5jO****`, which is in the `Deleted` state
 * *   `rs-PqysnzIj****`, which is in the `Active` state
 *
 * @param request ListResourceSharesRequest
 * @return ListResourceSharesResponse
 */
async function listResourceShares(request: ListResourceSharesRequest): ListResourceSharesResponse {
  var runtime = new Util.RuntimeOptions{};
  return listResourceSharesWithOptions(request, runtime);
}

model ListSharedResourcesRequest {
  maxResults?: int32(name='MaxResults', description='The maximum number of entries to return for a single request.

Valid values: 1 to 100. Default value: 20.', example='20'),
  nextToken?: string(name='NextToken', description='The `token` that is used to initiate the next request. If the response of the current request is truncated, you can use the token to initiate another request and obtain the remaining records.', example='TGlzdFJlc291cm****'),
  resourceIds?: [ string ](name='ResourceIds', description='The ID of a shared resource.', example='vsw-bp1upw03qyz8n7us9****'),
  resourceOwner?: string(name='ResourceOwner', description='The owner of the resource shares. Valid values:

*   Self: your account. If you set the value to Self, the resources you share with other accounts are queried.
*   OtherAccounts: another account. If you set the value to OtherAccounts, the resources other accounts share with you are queried.

This parameter is required.', example='Self'),
  resourceShareIds?: [ string ](name='ResourceShareIds', description='The ID of a resource share.', example='rs-6GRmdD3X****'),
  resourceType?: string(name='ResourceType', description='The type of the shared resources.

For more information about the types of resources that can be shared, see [Services that work with Resource Sharing](https://help.aliyun.com/document_detail/450526.html).', example='VSwitch'),
  target?: string(name='Target', description='The ID of the principal or resource owner.

*   If the value of `ResourceOwner` is `Self`, set this parameter to the ID of a principal.
*   If the value of `ResourceOwner` is `OtherAccounts`, set this parameter to the ID of a resource owner.', example='172050525300****'),
}

model ListSharedResourcesResponseBody = {
  nextToken?: string(name='NextToken', description='The token that is used to initiate the next request. If the response of the current request is truncated, you can use the token to initiate another request and obtain the remaining records.', example='TGlzdFJlc291cm****'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='04677DCA-7C33-464B-8811-1B1DA3C3D197'),
  sharedResources?: [ 
    {
      createTime?: string(name='CreateTime', description='The time when the shared resource was associated with the resource share.', example='2020-12-07T07:39:02.921Z'),
      resourceId?: string(name='ResourceId', description='The ID of the shared resource.', example='vsw-bp1upw03qyz8n7us9****'),
      resourceShareId?: string(name='ResourceShareId', description='The ID of the resource share.', example='rs-6GRmdD3X****'),
      resourceStatus?: string(name='ResourceStatus', description='The status of the shared resource. This parameter is returned only when you query the resources that other accounts share with you.

Valid values:

*   Available: The resource is available.
*   ZonalResourceInaccessible: The resource is unavailable in the current zone.
*   LimitExceeded: The resource is unavailable because the maximum number of resources that other accounts can share with you exceeds the upper limit.
*   Unavailable: The resource is unavailable.', example='Available'),
      resourceStatusMessage?: string(name='ResourceStatusMessage', description='The cause of the association failure.', example='The reason for the association failure.'),
      resourceType?: string(name='ResourceType', description='The type of the shared resource.

For more information about the types of resources that can be shared, see [Services that work with Resource Sharing](https://help.aliyun.com/document_detail/450526.html).', example='VSwitch'),
      updateTime?: string(name='UpdateTime', description='The time when the association of the shared resource was updated.', example='2020-12-07T07:39:02.921Z'),
    }
  ](name='SharedResources', description='The information of the shared resources.'),
}

model ListSharedResourcesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListSharedResourcesResponseBody(name='body'),
}

/**
 * @summary Queries the resources you share with other accounts or the resources other accounts share with you.
 *
 * @description This topic provides an example on how to call the API operation to query the resources that you share with other accounts in the `cn-hangzhou` region. The response shows that in the resource share `rs-6GRmdD3X****`, you share the `vsw-bp1upw03qyz8n7us9****` resource of the `VSwitch` type with other accounts.
 *
 * @param request ListSharedResourcesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListSharedResourcesResponse
 */
async function listSharedResourcesWithOptions(request: ListSharedResourcesRequest, runtime: Util.RuntimeOptions): ListSharedResourcesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.maxResults)) {
    query['MaxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.resourceIds)) {
    query['ResourceIds'] = request.resourceIds;
  }
  if (!Util.isUnset(request.resourceOwner)) {
    query['ResourceOwner'] = request.resourceOwner;
  }
  if (!Util.isUnset(request.resourceShareIds)) {
    query['ResourceShareIds'] = request.resourceShareIds;
  }
  if (!Util.isUnset(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  if (!Util.isUnset(request.target)) {
    query['Target'] = request.target;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListSharedResources',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries the resources you share with other accounts or the resources other accounts share with you.
 *
 * @description This topic provides an example on how to call the API operation to query the resources that you share with other accounts in the `cn-hangzhou` region. The response shows that in the resource share `rs-6GRmdD3X****`, you share the `vsw-bp1upw03qyz8n7us9****` resource of the `VSwitch` type with other accounts.
 *
 * @param request ListSharedResourcesRequest
 * @return ListSharedResourcesResponse
 */
async function listSharedResources(request: ListSharedResourcesRequest): ListSharedResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  return listSharedResourcesWithOptions(request, runtime);
}

model ListSharedTargetsRequest {
  maxResults?: int32(name='MaxResults', description='The maximum number of entries to return for a single request.

Valid values: 1 to 100. Default value: 20.', example='20'),
  nextToken?: string(name='NextToken', description='The pagination token that is used in the next request to retrieve a new page of results. You do not need to specify this parameter for the first request. You must specify the token that is obtained from the previous query as the value of `NextToken`.', example='TGlzdFJlc291cm****'),
  resourceId?: string(name='ResourceId', description='The ID of the shared resource.', example='vsw-bp1upw03qyz8n7us9****'),
  resourceOwner?: string(name='ResourceOwner', description='The owner of the resource share.

*   Self: your account. If you set the value to Self, the principals that are associated with your resource shares are queried.
*   OtherAccounts: another account. If you set the value to OtherAccounts, the resource shares with which your account is associated and the owners of the resource shares are queried.

This parameter is required.', example='Self'),
  resourceShareIds?: [ string ](name='ResourceShareIds', description='The ID of a resource share.

Valid values of N: 1 to 5. This indicates that a maximum of five resource shares can be specified at a time.', example='rs-6GRmdD3X****'),
  resourceType?: string(name='ResourceType', description='The type of the shared resources.

For more information about the types of resources that can be shared, see [Services that work with Resource Sharing](https://help.aliyun.com/document_detail/450526.html).', example='VSwitch'),
  targets?: [ string ](name='Targets', description='The information about the principals.', example='114240524784****'),
}

model ListSharedTargetsResponseBody = {
  nextToken?: string(name='NextToken', description='The pagination token that is used in the next request to retrieve a new page of results. You do not need to specify this parameter for the first request. You must specify the token that is obtained from the previous query as the value of `NextToken`.', example='TGlzdFJlc291cm****'),
  requestId?: string(name='RequestId', description='The request ID.', example='04677DCA-7C33-464B-8811-1B1DA3C3D197'),
  sharedTargets?: [ 
    {
      createTime?: string(name='CreateTime', description='The time when the principal was associated with the resource share.', example='2020-12-07T09:16:59.905Z'),
      external?: boolean(name='External', description='Indicates whether the principal is outside the resource directory. Valid values:

*   true
*   false', example='false'),
      resourceShareId?: string(name='ResourceShareId', description='The ID of the resource share.', example='rs-6GRmdD3X****'),
      targetId?: string(name='TargetId', description='The ID of the principal or resource owner.

*   If the value of `ResourceOwner` is `Self`, the value of this parameter is the ID of a principal.
*   If the value of `ResourceOwner` is `OtherAccounts`, the value of this parameter is the ID of a resource owner.', example='114240524784****'),
      targetProperty?: string(name='TargetProperty', description='The properties of the principal, such as the time range within which the resource is shared.

>  This parameter is returned only if the principal is an Alibaba Cloud service.', example='{
    "timeRange":{
        "timeRangeType":"timeRange",
        "beginAtTime":"00:00",
        "timezone":"UTC+8",
        "endAtTime":"19:59"
    }
}'),
      updateTime?: string(name='UpdateTime', description='The time when the association of the principal was updated.', example='2020-12-07T09:16:59.905Z'),
    }
  ](name='SharedTargets', description='The information of the principals.'),
}

model ListSharedTargetsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListSharedTargetsResponseBody(name='body'),
}

/**
 * @summary Queries principals.
 *
 * @description If you are a resource owner, you can query the principals with which you share your resources. If you are a principal, you can query the resources that are shared with you.
 * This topic provides an example on how to call the API operation to query the principals with which you share your resources in the `cn-hangzhou` region. The response shows that you share your resources with the principals `114240524784****` and `172050525300****`.
 *
 * @param request ListSharedTargetsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListSharedTargetsResponse
 */
async function listSharedTargetsWithOptions(request: ListSharedTargetsRequest, runtime: Util.RuntimeOptions): ListSharedTargetsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.maxResults)) {
    query['MaxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.resourceId)) {
    query['ResourceId'] = request.resourceId;
  }
  if (!Util.isUnset(request.resourceOwner)) {
    query['ResourceOwner'] = request.resourceOwner;
  }
  if (!Util.isUnset(request.resourceShareIds)) {
    query['ResourceShareIds'] = request.resourceShareIds;
  }
  if (!Util.isUnset(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  if (!Util.isUnset(request.targets)) {
    query['Targets'] = request.targets;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListSharedTargets',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries principals.
 *
 * @description If you are a resource owner, you can query the principals with which you share your resources. If you are a principal, you can query the resources that are shared with you.
 * This topic provides an example on how to call the API operation to query the principals with which you share your resources in the `cn-hangzhou` region. The response shows that you share your resources with the principals `114240524784****` and `172050525300****`.
 *
 * @param request ListSharedTargetsRequest
 * @return ListSharedTargetsResponse
 */
async function listSharedTargets(request: ListSharedTargetsRequest): ListSharedTargetsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listSharedTargetsWithOptions(request, runtime);
}

model ListTagResourcesRequest {
  nextToken?: string(name='NextToken', example='caeba0bbb2be03f84eb48b699f0a****'),
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-hangzhou'),
  resourceId?: [ string ](name='ResourceId'),
  resourceType?: string(name='ResourceType', description='This parameter is required.', example='ResourceShare'),
  tag?: [ 
    {
      key?: string(name='Key', example='k1'),
      value?: string(name='Value', example='v1'),
    }
  ](name='Tag'),
}

model ListTagResourcesResponseBody = {
  nextToken?: string(name='NextToken', example='caeba0bbb2be03f84eb48b699f0a****'),
  requestId?: string(name='RequestId', example='8054B059-6B36-53BF-AA45-B8C9A0ED05AB'),
  tagResources?: {
    tagResource?: [ 
    {
      resourceId?: string(name='ResourceId', example='rs-PqysnzIj****'),
      resourceType?: string(name='ResourceType', example='ResourceShare'),
      tagKey?: string(name='TagKey', example='k1'),
      tagValue?: string(name='TagValue', example='v1'),
    }
  ](name='TagResource')
  }(name='TagResources'),
}

model ListTagResourcesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListTagResourcesResponseBody(name='body'),
}

/**
 * @summary 查询资源标签
 *
 * @param request ListTagResourcesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListTagResourcesResponse
 */
async function listTagResourcesWithOptions(request: ListTagResourcesRequest, runtime: Util.RuntimeOptions): ListTagResourcesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceId)) {
    query['ResourceId'] = request.resourceId;
  }
  if (!Util.isUnset(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  if (!Util.isUnset(request.tag)) {
    query['Tag'] = request.tag;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListTagResources',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 查询资源标签
 *
 * @param request ListTagResourcesRequest
 * @return ListTagResourcesResponse
 */
async function listTagResources(request: ListTagResourcesRequest): ListTagResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  return listTagResourcesWithOptions(request, runtime);
}

model RejectResourceShareInvitationRequest {
  resourceShareInvitationId?: string(name='ResourceShareInvitationId', description='The ID of the resource sharing invitation.

You can call the [ListResourceShareInvitations](https://help.aliyun.com/document_detail/450564.html) operation to obtain the ID of a resource sharing invitation.

This parameter is required.', example='i-yyTWbkjHArYh****'),
}

model RejectResourceShareInvitationResponseBody = {
  requestId?: string(name='RequestId', description='The ID of the request.', example='E446D6DE-BFC8-5F37-A494-33D7B118147D'),
  resourceShareInvitation?: {
    createTime?: string(name='CreateTime', description='The time when the invitation was created. The time is displayed in UTC.

This parameter is required.', example='2022-09-02T07:07:30.809Z'),
    receiverAccountId?: string(name='ReceiverAccountId', description='The Alibaba Cloud account ID of the invitee.

This parameter is required.', example='134254031178****'),
    resourceShareId?: string(name='ResourceShareId', description='The ID of the resource share.

This parameter is required.', example='rs-JoA1Ayjm****'),
    resourceShareInvitationId?: string(name='ResourceShareInvitationId', description='The ID of the invitation.

This parameter is required.', example='i-yyTWbkjHArYh****'),
    resourceShareName?: string(name='ResourceShareName', description='The name of the resource share.

This parameter is required.', example='example'),
    senderAccountId?: string(name='SenderAccountId', description='The Alibaba Cloud account ID of the inviter.

This parameter is required.', example='151266687691****'),
    status?: string(name='Status', description='The status of the invitation. Valid values:

*   Pending: The invitation is waiting for confirmation.
*   Accepted: The invitation is accepted.
*   Cancelled: The invitation is canceled.
*   Rejected: The invitation is rejected.
*   Expired: The invitation has expired.

This parameter is required.', example='Rejected'),
  }(name='ResourceShareInvitation', description='The information of the resource sharing invitation.'),
}

model RejectResourceShareInvitationResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: RejectResourceShareInvitationResponseBody(name='body'),
}

/**
 * @summary 拒绝组织外共享邀请
 *
 * @description This topic provides an example on how to call the API operation to reject the resource sharing invitation `i-yyTWbkjHArYh****` in the `cn-hangzhou` region.
 *
 * @param request RejectResourceShareInvitationRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return RejectResourceShareInvitationResponse
 */
async function rejectResourceShareInvitationWithOptions(request: RejectResourceShareInvitationRequest, runtime: Util.RuntimeOptions): RejectResourceShareInvitationResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.resourceShareInvitationId)) {
    query['ResourceShareInvitationId'] = request.resourceShareInvitationId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'RejectResourceShareInvitation',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 拒绝组织外共享邀请
 *
 * @description This topic provides an example on how to call the API operation to reject the resource sharing invitation `i-yyTWbkjHArYh****` in the `cn-hangzhou` region.
 *
 * @param request RejectResourceShareInvitationRequest
 * @return RejectResourceShareInvitationResponse
 */
async function rejectResourceShareInvitation(request: RejectResourceShareInvitationRequest): RejectResourceShareInvitationResponse {
  var runtime = new Util.RuntimeOptions{};
  return rejectResourceShareInvitationWithOptions(request, runtime);
}

model TagResourcesRequest {
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-hangzhou'),
  resourceId?: [ string ](name='ResourceId', description='This parameter is required.'),
  resourceType?: string(name='ResourceType', description='This parameter is required.', example='ResourceShare'),
  tag?: [ 
    {
      key?: string(name='Key', example='k1'),
      value?: string(name='Value', example='v1'),
    }
  ](name='Tag', description='This parameter is required.'),
}

model TagResourcesResponseBody = {
  requestId?: string(name='RequestId', example='E7747EDF-EDDC-5B38-9B6A-6392B9C92B1C'),
}

model TagResourcesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: TagResourcesResponseBody(name='body'),
}

/**
 * @summary 资源打用户标签
 *
 * @param request TagResourcesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return TagResourcesResponse
 */
async function tagResourcesWithOptions(request: TagResourcesRequest, runtime: Util.RuntimeOptions): TagResourcesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceId)) {
    query['ResourceId'] = request.resourceId;
  }
  if (!Util.isUnset(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  if (!Util.isUnset(request.tag)) {
    query['Tag'] = request.tag;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'TagResources',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 资源打用户标签
 *
 * @param request TagResourcesRequest
 * @return TagResourcesResponse
 */
async function tagResources(request: TagResourcesRequest): TagResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  return tagResourcesWithOptions(request, runtime);
}

model UntagResourcesRequest {
  all?: boolean(name='All', example='false'),
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-hangzhou'),
  resourceId?: [ string ](name='ResourceId'),
  resourceType?: string(name='ResourceType', description='This parameter is required.', example='ResourceShare'),
  tagKey?: [ string ](name='TagKey'),
}

model UntagResourcesResponseBody = {
  requestId?: string(name='RequestId', example='E7747EDF-EDDC-5B38-9B6A-6392B9C92B1C'),
}

model UntagResourcesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UntagResourcesResponseBody(name='body'),
}

/**
 * @summary 资源去除用户标签
 *
 * @param request UntagResourcesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return UntagResourcesResponse
 */
async function untagResourcesWithOptions(request: UntagResourcesRequest, runtime: Util.RuntimeOptions): UntagResourcesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.all)) {
    query['All'] = request.all;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceId)) {
    query['ResourceId'] = request.resourceId;
  }
  if (!Util.isUnset(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  if (!Util.isUnset(request.tagKey)) {
    query['TagKey'] = request.tagKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'UntagResources',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 资源去除用户标签
 *
 * @param request UntagResourcesRequest
 * @return UntagResourcesResponse
 */
async function untagResources(request: UntagResourcesRequest): UntagResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  return untagResourcesWithOptions(request, runtime);
}

model UpdateResourceShareRequest {
  allowExternalTargets?: boolean(name='AllowExternalTargets', description='Specifies whether resources in the resource share can be shared with accounts outside the resource directory. Valid values:

*   false: Resources in the resource share can be shared only with accounts in the resource directory.
*   true: Resources in the resource share can be shared with both accounts in the resource directory and accounts outside the resource directory.', example='false'),
  resourceShareId?: string(name='ResourceShareId', description='The ID of the resource share.

This parameter is required.', example='rs-qSkW1HBY****'),
  resourceShareName?: string(name='ResourceShareName', description='The new name of the resource share.

The name must be 1 to 50 characters in length.

The name can contain letters, digits, periods (.), underscores (_), and hyphens (-).

This parameter is required.', example='new'),
}

model UpdateResourceShareResponseBody = {
  requestId?: string(name='RequestId', description='The ID of the request.', example='2860A3A4-D8C1-4EF4-954E-84A3945E26E5'),
  resourceShare?: {
    allowExternalTargets?: boolean(name='AllowExternalTargets', description='Indicates whether resources in the resource share can be shared with accounts outside the resource directory. Valid values:

*   false: Resources in the resource share can be shared only with accounts in the resource directory.
*   true: Resources in the resource share can be shared with both accounts in the resource directory and accounts outside the resource directory.', example='false'),
    createTime?: string(name='CreateTime', description='The time when the resource share was created.', example='2020-12-03T08:02:22.413Z'),
    resourceShareId?: string(name='ResourceShareId', description='The ID of the resource share.', example='rs-qSkW1HBY****'),
    resourceShareName?: string(name='ResourceShareName', description='The name of the resource share.', example='new'),
    resourceShareOwner?: string(name='ResourceShareOwner', description='The owner of the resource share.', example='151266687691****'),
    resourceShareStatus?: string(name='ResourceShareStatus', description='The status of the resource share. Valid values:

*   Active: The resource share is enabled.
*   Pending: The resource share is associated with one or more resource sharing invitations that are waiting for confirmation.
*   Deleting: The resource share is being deleted.
*   Deleted: The resource share is deleted.

>  The system deletes the records of resource shares in the Deleted state within 48 hours to 96 hours after you delete the resource shares.', example='Active'),
    updateTime?: string(name='UpdateTime', description='The time when the resource share was updated.', example='2020-12-04T08:55:25.382Z'),
  }(name='ResourceShare', description='The information of the resource share.'),
}

model UpdateResourceShareResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateResourceShareResponseBody(name='body'),
}

/**
 * @summary 调用UpdateResourceShare修改共享单元基本信息。
 *
 * @description You can call this API operation to change the name or resource sharing scope of a resource share.
 * This topic provides an example on how to call the API operation to change the name of the resource share `rs-qSkW1HBY****` in the `cn-hangzhou` region from `test` to `new`.
 *
 * @param request UpdateResourceShareRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateResourceShareResponse
 */
async function updateResourceShareWithOptions(request: UpdateResourceShareRequest, runtime: Util.RuntimeOptions): UpdateResourceShareResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.allowExternalTargets)) {
    query['AllowExternalTargets'] = request.allowExternalTargets;
  }
  if (!Util.isUnset(request.resourceShareId)) {
    query['ResourceShareId'] = request.resourceShareId;
  }
  if (!Util.isUnset(request.resourceShareName)) {
    query['ResourceShareName'] = request.resourceShareName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'UpdateResourceShare',
    version = '2020-01-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 调用UpdateResourceShare修改共享单元基本信息。
 *
 * @description You can call this API operation to change the name or resource sharing scope of a resource share.
 * This topic provides an example on how to call the API operation to change the name of the resource share `rs-qSkW1HBY****` in the `cn-hangzhou` region from `test` to `new`.
 *
 * @param request UpdateResourceShareRequest
 * @return UpdateResourceShareResponse
 */
async function updateResourceShare(request: UpdateResourceShareRequest): UpdateResourceShareResponse {
  var runtime = new Util.RuntimeOptions{};
  return updateResourceShareWithOptions(request, runtime);
}

